﻿@extends('layouts.shop_main')

@section('title', '专属二维码')

@section('resources')
    @parent
    <style>
        .header{margin: 0 30px 20px 30px;padding: 10px 0;overflow: hidden;border-bottom: 1px solid #eee;}
        .header p{float: left;font-size: 18px;overflow: hidden;}
        .header p span{float: left;font-size: 18px;margin-right: 10px;}
        .order_content{margin: 0 30px;}
        .order_content .title{position: relative;height: 35px;margin-top: 20px;}
        .order_content .title span{font-size: 18px;border-left: 3px solid #9955c6;padding: 0 20px;position: absolute;top: 0;left: 0;background-color: #fff;}
        .order_content .title p{border-bottom: 1px solid #eee;float: left;position: absolute;top: 13px;left: 0;width: 100%;}
        .qrcode_content{overflow: hidden;}
        .erweima{float: left;}
        .shop_name{float: left;overflow: hidden;margin-left: 60px;margin-top: 85px;}
        .shop_name span{float: left;width: 100%;font-size: 16px;margin-bottom: 15px;}
    </style>
@endsection

@section('content')
	<div class="content">
        <div class="header">
            <p>专属二维码</p>
        </div>
        <section class="order_content">
            <ul>
            @foreach($lists as $list)
                <li>
                    <div class="title">
                    @if(!isset($i))
                        <p style="display: none;">{{$i=1}}</p>
                    @else
                        <p style="display: none;">{{++$i}}</p>
                    @endif
                        <span>{{$list['shopname']}}</span>
                    </div>
                    <div class="qrcode_content">
                        <p class="erweima">
                            <span id="output_{{$i}}"></span>
                        </p>
                        <input type="hidden" name="index_{{$i}}" value="{{$list['shopid']}}">
                        <p class="shop_name">
                            <span>{{$list['shopname']}}</span>
                            <span style="font-size: 14px;color: #808080;">{{$list['address']}}</span>
                            <button onclick="download_qrocde('{{$list['shopid']}}')">下载</button>
                        </p>
                    </div>
                </li>
            @endforeach
            </ul>
        </section>
    </div>
@endsection

@section('scriptResources')
    @parent
    <script type="text/javascript" src="{{env('JS_DOMAIN')}}js/jquery.qrcode.min.js"></script>
    <script>
        var count = '{{$count}}';
        var web_url = '{{env('WEB_URL')}}';
        if(count>0) {
            for(var i=1; i<=count; i++) {
                var shop_id = $("input[name='index_"+i+"']").val();
                $('#output_'+i).qrcode(web_url + 'qrcode/shop/'+ shop_id);
            }
        }
        //下载二维码
        function download_qrocde(shopid) {
            window.location.href="/shop/qrcode/shop/qrcode/download?shopid="+shopid;
        }
    </script>
@endsection